/** 
 *  @file
 *  @brief   箱形（BOX）梁截面属性使用解析公式计算类
 *  @author  duweixing
 *  @date    2024.04.17
 *  @version v1.0
 *  @par Copyright(c):  ShenGong  Simulation corporation
 */

#include "BoxSectionFormulaCalculator.h"
#include "DataStructure/Common/Real.h"

using SG::DataStructure::Common::Real;
using SG::DataStructure::FEM::PBARLData;
using SG::DataStructure::FEM::PBARData;
using SG::FEMSolver::Element::BoxSectionFormulaCalculator;

void BoxSectionFormulaCalculator::Compute
(
const SG::DataStructure::FEM::PBARLData& section,
_OUT SG::DataStructure::FEM::PBARData&   property,
_OUT SG::Algebra::Point&                 centroid
) const
{
    Real b{section.m_dimension[0]};
    Real h{section.m_dimension[1]};
    Real t2{section.m_dimension[3]};
    Real t1{section.m_dimension[2]};
    Real bi{b - 2.0 * t2};
    Real hi{h - 2.0 * t1};

    property.m_id  = section.m_id;
    property.m_mId = section.m_mId;
    property.m_A   = b * h - bi * hi;
    // Real yS = 0.0;
    // Real zS = 0.0;
    // Real yC = 0.0;
    // Real zC = 0.0;
    property.m_I1  = (b * h * h * h - bi * hi * hi * hi) / 12.0;
    property.m_I2  = (h * b * b * b - hi * bi * bi * bi) / 12.0;
    property.m_I12 = 0.0;
    property.m_J   = 2.0 * t2 * t1 * (b - t2) * (b - t2) * (h - t1) * (h - t1) / (b * t2 + h * t1 - t2 * t2 - t1 * t1);
    property.m_K1  = 2.0 * hi * t2 / property.m_A;
    property.m_K2  = 2.0 * bi * t1 / property.m_A;
    property.m_NSM = section.m_nsm;
    property.m_FE  = 0.0;
    property.SetStressPoints ({ 0.5 * h,  0.5 * b,
                               -0.5 * h,  0.5 * b,
                               -0.5 * h, -0.5 * b,
                                0.5 * h, -0.5 * b});
    centroid.m_x = 0.0;
    centroid.m_y = 0.0;
    centroid.m_z = 0.0;
}